Social Network Analysis for Startups by Kouznetsov Alexander Tsvetovat Maksim
Author:Kouznetsov, Alexander, Tsvetovat, Maksim [Maksim Tsvetovat and Alexander Kouznetsov]
Language: eng
Format: epub
Tags: COMPUTERS / Social Aspects / General
ISBN: 9781449317621
Publisher: O'Reilly Media, Inc.
Published: 2011-09-26T16:00:00+00:00
Figure 4-11. Block model of the Caucasus
A slightly more involved drawing mechanism that works on all graphs can be found in hiclus_blockmodel.py:
Example 4-2. Draw a network and its block model side by side
__author__ = """\n""".join(['Maksim Tsvetovat <[email protected]', 'Drew Conway <[email protected]>', 'Aric Hagberg <[email protected]>']) from collections import defaultdict import networkx as nx import numpy from scipy.cluster import hierarchy from scipy.spatial import distance import matplotlib.pyplot as plt import hc """Draw a blockmodel diagram of a clustering alongside the original network""" def hiclus_blockmodel(G): # Extract largest connected component into graph H H=nx.connected_component_subgraphs(G)[0] # Create parititions with hierarchical clustering partitions=hc.create_hc(H) # Build blockmodel graph BM=nx.blockmodel(H,partitions) # Draw original graph pos=nx.spring_layout(H,iterations=100) fig=plt.figure(1,figsize=(6,10)) ax=fig.add_subplot(211) nx.draw(H,pos,with_labels=False,node_size=10) plt.xlim(0,1) plt.ylim(0,1) # Draw block model with weighted edges and nodes sized by # number of internal nodes node_size=[BM.node[x]['nnodes']*10 for x in BM.nodes()] edge_width=[(2*d['weight']) for (u,v,d) in BM.edges(data=True)] # Set positions to mean of positions of internal nodes from original graph posBM={} for n in BM: xy=numpy.array([pos[u] for u in BM.node[n]['graph']]) posBM[n]=xy.mean(axis=0) ax=fig.add_subplot(212) nx.draw(BM,posBM,node_size=node_size,width=edge_width,with_labels=False) plt.xlim(0,1) plt.ylim(0,1) plt.axis('off')
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(14616)
The Mikado Method by Ola Ellnestam Daniel Brolund(11877)
Hello! Python by Anthony Briggs(11791)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(11240)
Dependency Injection in .NET by Mark Seemann(11001)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10518)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(9832)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(9420)
Grails in Action by Glen Smith Peter Ledbrook(9165)
Hit Refresh by Satya Nadella(9038)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(8808)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(8594)
The Kubernetes Operator Framework Book by Michael Dame(8470)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(8309)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8290)
Robo-Advisor with Python by Aki Ranin(8245)
Practical Computer Architecture with Python and ARM by Alan Clements(8217)
Implementing Enterprise Observability for Success by Manisha Agrawal and Karun Krishnannair(8189)
Building Low Latency Applications with C++ by Sourav Ghosh(8091)